package com.fire.service.impl;

import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.fire.bo.collage.req.CollageGoodListReq;
import com.fire.bo.collage.req.CollageGoodNumListReq;
import com.fire.bo.collage.req.CollageGoodReq;
import com.fire.bo.collage.req.CollageGoodStatusReq;
import com.fire.bo.collage.req.GofireNameReq;
import com.fire.bo.collage.req.GofireProductReq;
import com.fire.bo.collage.req.GofireReq;
import com.fire.bo.collage.res.CollageGoodListRes;
import com.fire.bo.collage.res.CollageGoodNumListRes;
import com.fire.bo.collage.res.GofireProductRes;
import com.fire.bo.collage.res.GofireRes;
import com.fire.bo.coupon.req.DelCouponReq;
import com.fire.dao.CollageGoodDao;
import com.fire.service.CollageGoodService;

@Service
public class CollageGoodServiceImpl implements CollageGoodService
{

	@Autowired
	private CollageGoodDao collageGoodDao;

	@Override
	@Transactional
	public void addCollageGoodNum(CollageGoodReq bean) throws SQLException {
		Map<String, Object> map = new HashMap<>();
		
		map.put("id", bean.getGoodId());
		
		map.put("overNum", bean.getCollageNum());
		
		Map<String, Object> mapCollage = collageGoodDao.getCollageProject(map);
		
		collageGoodDao.addCollagerProject(mapCollage);
		collageGoodDao.addCollageGoodNum(bean);
	}

	@Override
	public void updateCollageGoodStatus(CollageGoodStatusReq bean) throws SQLException {
		collageGoodDao.updateCollageGoodStatus(bean);
	}

	@Override
	public List<CollageGoodListRes> findGoodList(CollageGoodListReq bean) throws SQLException {
		
		bean.setPage((bean.getPage() - 1) * bean.getPageSize());
		
		return collageGoodDao.findGoodList(bean);
	}
	
	@Override
	public List<CollageGoodNumListRes> findGoodNumList(CollageGoodNumListReq bean) throws SQLException {
		return collageGoodDao.findGoodNumList(bean);
	}

	@Override
	public int findGoodListCount(CollageGoodListReq bean) throws SQLException {
		return collageGoodDao.findGoodListCount(bean);
	}

	@Override
	public void addGofireProject(GofireProductRes bean) throws SQLException {
		collageGoodDao.addGofireProject(bean);
	}

	

	@Override
	public List<GofireProductRes> gofireProjectList(GofireProductReq bean) throws SQLException {
		bean.setPage((bean.getPage()-1)*bean.getPageSize());
		return collageGoodDao.gofireProjectList(bean);
	}

	@Override
	public GofireProductRes gofireProjectById(DelCouponReq bean) throws SQLException {
		return collageGoodDao.gofireProjectById(bean);
	}

	@Override
	public void updateGofireProject(GofireProductRes bean) throws SQLException {
		collageGoodDao.updateGofireProject(bean);
	}

	@Override
	public void delgofireProject(DelCouponReq bean) throws SQLException {
		collageGoodDao.delgofireProject(bean);
	}

	@Override
	public int gofireProjectListCount(GofireProductReq bean) throws SQLException {
		return collageGoodDao.gofireProjectListCount(bean);
	}

	@Override
	public int collageCount(Map<String, Object> map) throws SQLException {
		return collageGoodDao.collageCount(map);
	}

	@Override
	public void addGoFire(GofireReq info) throws SQLException {
		collageGoodDao.addGoFire(info);
	}

	@Override
	public void updateGoFire(GofireRes info) throws SQLException {
		collageGoodDao.updateGoFire(info);
	}

	@Override
	public List<GofireRes> findAllFireRes(GofireNameReq info) throws SQLException {
		info.setPage((info.getPage() - 1) * info.getPageSize());
		return collageGoodDao.findAllFireRes(info);
	}

	@Override
	public int findAllFireResCount(GofireNameReq info) throws SQLException {
		return collageGoodDao.findAllFireResCount(info);
	}

	@Override
	public GofireRes findFireResInfo(DelCouponReq info) throws SQLException {
		return collageGoodDao.findFireResInfo(info);
	}

	

}
